package com.dacool.view;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Path;
import android.graphics.RectF;
import android.graphics.Region;
import android.widget.ImageView;

public class RoundRectImageView extends ImageView {

	private int radius;

	public void setRadius(int radius) {
		this.radius = radius;
	}

	
	
	public int radius() {
		return this.radius;
	}

	public RoundRectImageView(Context context) {
		super(context);
		this.setScaleType(ScaleType.CENTER_CROP);
		// TODO Auto-generated constructor stub
	}

	@Override
	protected void onDraw(Canvas canvas) {
		Path mPath = new Path();
		mPath.addRoundRect(new RectF(0, 0, getWidth(), getHeight()), radius, radius,
				Path.Direction.CCW);
		canvas.clipPath(mPath, Region.Op.INTERSECT);
		
		super.onDraw(canvas);
	}
}
